#ifndef BRE_EEG_DATASTRUCT_H
#define BRE_EEG_DATASTRUCT_H

#include <stdint.h>
#include <iostream>
/***************************************************
 * mode name:BRE_EEG_dataStruct
 * brief:放大器数据包的结构
 * @author yxt
 * @created 2024/06/03 11:24:30
 * @imfor ~/bigSystem/closedLoop_regulation/include/collectData/BRE_EEG_dataStruct.h
 * @modify:
 * 		
* 	基于
        文件: TcpEEG.h
        作者：张欢
        版本：3.0
        完成日期：2022年3月16日
***************************************************/

#define BYTE unsigned char


// 一个通道一帧数据的组织形式
typedef struct _TCPEEG_DATA_UNIT
{
	BYTE high;
	BYTE middle;
	BYTE low;
} TCPEEG_DATA_UNIT;

#define TCPEEG_CHANNEL_COUNT 64 // 通道数
#define TCPEEG_HEAD_1 0XAA	// 一个包开头的2字节标志
#define TCPEEG_HEAD_2 0X55
typedef struct _TCPEEG_PACK
{
	BYTE head[2];	// 一个包开头的标志
	BYTE mark;	// mark
	BYTE impendance[8];	// 8个字节的脱落检测
	TCPEEG_DATA_UNIT data[TCPEEG_CHANNEL_COUNT];
    BYTE battery;
} TCPEEG_PACK;

typedef struct ImpendanceFlag_typedefStruct ImpendanceFlag;
typedef struct ImpendanceFlag_typedefStruct 
{
	uint8_t FP1:1;
	uint8_t FPZ:1;
	uint8_t FP2:1;
	uint8_t AF3:1;
	uint8_t AF4:1;
	uint8_t F7:1;
	uint8_t F5:1;
	uint8_t F3:1;
	uint8_t F1:1;
	uint8_t FZ:1;
	uint8_t F2:1;
	uint8_t F4:1;
	uint8_t F6:1;
	uint8_t F8:1;
	uint8_t FT7:1;
	uint8_t FC5:1;
	uint8_t FC3:1;
	uint8_t FC1:1;
	uint8_t FCZ:1;
	uint8_t FC2:1;
	uint8_t FC4:1;
	uint8_t FC6:1;
	uint8_t FT8:1;
	uint8_t T7:1;
	uint8_t C5:1;
	uint8_t C3:1;
	uint8_t C1:1;
	uint8_t CZ:1;
	uint8_t C2:1;
	uint8_t C4:1;
	uint8_t C6:1;
	uint8_t T8:1;
	uint8_t M1:1;
	uint8_t TP7:1;
	uint8_t CP5:1;
	uint8_t CP3:1;
	uint8_t CP1:1;
	uint8_t CPZ:1;
	uint8_t CP2:1;
	uint8_t CP4:1;
	uint8_t CP6:1;
	uint8_t TP8:1;
	uint8_t M2:1;
	uint8_t P7:1;
	uint8_t P5:1;
	uint8_t P3:1;
	uint8_t P1:1;
	uint8_t PZ:1;
	uint8_t P2:1;
	uint8_t P4:1;
	uint8_t P6:1;
	uint8_t P8:1;
	uint8_t PO7:1;
	uint8_t PO5:1;
	uint8_t PO3:1;
	uint8_t POZ:1;
	uint8_t PO4:1;
	uint8_t PO6:1;
	uint8_t PO8:1;
	uint8_t CB1:1;
	uint8_t O1:1;
	uint8_t OZ:1;
	uint8_t O2:1;
	uint8_t CB2:1;

}ImpendanceFlag;

// 换算出来的电压值
typedef struct _EEG_VOLTAGE
{
	double data[TCPEEG_CHANNEL_COUNT];
} EEG_VOLTAGE;
Q_DECLARE_METATYPE(EEG_VOLTAGE)

namespace SIM_EEGDEV{
enum Electrode_ID{
	FP1/* = 0*/,FPZ,FP2,F7,F3,FZ,F4,F8,
	FC5/* = 8*/,FC1,FC2,FC6,M1,T7,C3,CZ,
	C4/* = 16*/,T8,M2,CP5,CP1/* = 20*/,CP2,CP6,P7,
	P3/* = 24*/,PZ,P4,P8,POZ,O1,O2,/*EOG,*/
	AF7/* = 32*/,AF3,AF4,AF8,F5,F1,F2,F6,
	FC3/* = 40*/,FCZ,FC4,C5,C1,C2,C6,CP3,
	CP4/* = 48*/,P5,P1,P2,P6,PO5,PO3,PO4,
	PO6/* = 56*/,FT7,FT8,TP7,TP8/* = 60*/,PO7,PO8,OZ
};
}

namespace EEGDEV{
enum Electrode_ID{
	FP1 = 0,FPZ,FP2,AF3,AF4,F7,F5,F3,
	F1 = 8, FZ,F2,F4,F6,F8,FT7,FC5,
	FC3 = 16,FC1,FCZ,FC2,FC4 = 20,FC6,FT8,T7,
	C5 = 24,C3,C1,CZ,C2,C4,C6 = 30,T8,
	M1 = 32,TP7,CP5,CP3,CP1,CPZ,CP2,CP4,
	CP6 = 40,TP8,M2,P7,P5,P3,P1,PZ,
	P2 = 48,P4,P6 = 50,P8,PO7,PO5,PO3,POZ,
	PO4 = 56,PO6,PO8,CB1,O1,OZ,O2,CB2
};

static const uint16_t electrode_coordinate[64][2] = {
#if 0
	{306,198},// FP1
	{378,197},// FPZ
	{452,198},// FP2
	{303,249},// AF3
	{458,249},// AF4
	{167,277},// F7
	{216,296},// F5
	{268,316},// F3
	{322,322},// F1
	{378,326},// FZ
	{436,321},// F2
	{488,311},// F4
	{537,296},// F6
	{584,272},// F8
	{139,346},// FT7
	{185,378},// FC5
	{252,390},// FC3
	{318,395},// FC1
	{380,395},// FCZ
	{444,390},// FC2
	{509,384},// FC4
	{574,376},// FC6
	{615,342},// FT8
	{108,457},// T7
	{179,463},// C5
	{247,464},// C3
	{315,464},// C1
	{377,467},// CZ
	{445,464},// C2
	{511,463},// C4
	{578,459},// C6
	{647,457},// T8
	{110,514},// M1
	{133,548},// TP7
	{194,538},// CP5
	{258,534},// CP3
	{319,528},// CP1
	{0,0},// CPZ(图中没有cpz的点)
	{443,526},// CP2
	{503,528},// CP4
	{563,532},// CP6
	{626,543},// TP8
	{644,514},// M2
	{179,616},// P7
	{226,597},// P5
	{276,588},// P3
	{326,585},// P1
	{377,585},// PZ
	{430,584},// P2
	{481,588},// P4
	{530,597},// P6
	{576,614},// P8
	{239,662},// PO7
	{272,650},// PO5
	{302,638},// PO3
	{379,640},// POZ
	{455,642},// PO4
	{486,651},// PO6
	{518,661},// PO8
	{270,681},// CB1
	{309,687},// O1
	{377,689},// OZ
	{447,686},// O2
	{485,683} // CB2
#else
	{154,68},// FP1
	{198,67},// FPZ
	{243,68},// FP2
	{153,99},// AF3
	{247,99},// AF4
	{69,114},// F7
	{100,128},// F5
	{131,142},// F3
	{163,145},// F1
	{198,145},// FZ
	{234,144},// F2
	{266,138},// F4
	{295,128},// F6
	{324,114},// F8
	{51,158},// FT7
	{80,177},// FC5
	{122,186},// FC3
	{161,188},// FC1
	{199,189},// FCZ
	{240,185},// FC2
	{278,181},// FC4
	{319,177},// FC6
	{343,156},// FT8
	{34,212},// T7
	{77,219},// C5
	{118,220},// C3
	{160,220},// C1
	{199,223},// CZ
	{240,223},// C2
	{278,221},// C4
	{321,215},// C6
	{363,210},// T8
	{34,246},// M1
	{48,266},// TP7
	{84,262},// CP5
	{125,258},// CP3
	{163,254},// CP1
	{0,0},// CPZ(图中没有cpz的点)
	{236,254},// CP2
	{278,254},// CP4
	{311,258},// CP6
	{353,269},// TP8
	{363,246},// M2
	{66,308},// P7
	{103,294},// P5
	{135,287},// P3
	{165,286},// P1
	{199,286},// PZ
	{233,286},// P2
	{268,291},// P4
	{295,294},// P6
	{328,304},// P8
	{107,336},// PO7
	{132,325},// PO5
	{156,322},// PO3
	{198,320},// POZ
	{244,324},// PO4
	{270,328},// PO6
	{292,336},// PO8
	{132,354},// CB1
	{158,358},// O1
	{199,358},// OZ
	{241,358},// O2
	{268,354} // CB2
#endif
};


}







#endif // !BRE_EEG_DATASTRUCT_H

